package com.pan.io;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

public class WriteCSV {

    private File file;


    private FileWriter fileWriter;

    public WriteCSV(File file){
        this(file,true);
    }
    public WriteCSV(File file,boolean append){
        this.file = file;
        try {
            if (!file.exists()) {
                file.createNewFile();
            }
            fileWriter = new FileWriter(file,append);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public WriteCSV(String dirPathName,String fileName,boolean append) {
        this(new File(dirPathName+"\\"+fileName),append);
    }

    public void writerLine(String line){
        try {
            fileWriter.write(line);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public void close(){
        try {
            fileWriter.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }


}
